Skip to main content
Version: v1.1.0

Build a Plugin Package

Plugin Package is a uniform format to archive your Plugin, and you can distribute your Plugin on Plugin Center by Plugin Package.

Deployment

Following step will teach you how to pack your Plugin Package from source.

Deploy from Local

cmake --build build --target package

Then you should get Plugin Package plugIN-hello-0.0.0-linux-x86_64.tar.gz under build directory.

Deploy from Docker

Choose Dockerfile.x86_64 or Dockerfile.jetson depend on your target plarform, and output Plugin Package will output under OUTPUT_DIRECTORY.

docker build -f <Dockerfile.x86_64|Dockerfile.jetson> --output [OUTPUT_DIRECTROY] .

For example:

docker build -f Dockerfile.x86_64 --output build .

Then you should get Plugin Package plugIN-hello-0.0.0-linux-x86_64.tar.gz under OUTPUT_DIRECTORY directory.

How it works

Let's take a look at Plugin Package inside to understand how it composed.

plugin-hello-0.0.0-linux-x86_64.tar.gz
.
├── 8102220f-083f-4f11-a433-6ccb2e786fed
│   ├── plugin-hello
│   ├── plugin_alert.json
│   ├── plugin_command_ack.json
│   ├── plugin_state.json
│   ├── plugin_update_template.json
│   └── uninstall_plugIN.sh
└── install_plugIN.sh

1 directory, 7 files

What Plugin Installer Script install a Plugin just extract the Plugin Package and run the install_plugIN.sh, On the other side, run uninstall_plugIN.sh when uninstall.

Next, Let's find out how to implement install_plugIN.sh and uninstall_plugIN.sh. Check out the hello Plugin working directory.

plugin-hello
...
├── dep
│ ├── ...
├── resource_dir_linux
│   ├── install_plugIN.sh
│   ├── plugin_alert.json
│   ├── plugin_command_ack.json
│   ├── plugin_state.json
│   ├── plugin_update_template.json
│   └── uninstall_plugIN.sh
├── resource_dir_windows
│   ├── install_plugIN.bat
│   ├── plugin_alert.json
│   ├── plugin_command_ack.json
│   ├── plugin_state.json
│   ├── plugin_update_template.json
│   └── uninstall_plugIN.bat
└── src
├── ...

This project separate installed files by platform, all files under resource_dir_[PLATFORM] will be installed under target device.

You have to implement install_plugIN.sh, uninstall_plugIN.sh yourself. We will set installation path to environment variable ALLXON_PLUGIN_DIR when the script be called. So that you can install all you need under ALLXON_PLUGIN_DIR, same as windows.

caution

If you want, you don't necessary to follow installation path ALLXON_PLUGIN_DIR. At least, you must place uninstall_plugIN.sh under ALLXON_PLUGIN_DIR.

resource_dir_linux/install_plugIN.sh
#!/bin/bash
CURRENT_SH_DIRECTORY=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
exec &> "${CURRENT_SH_DIRECTORY}/$(basename "${BASH_SOURCE[0]%.*}").output"

PLUGIN_NAME=plugin-hello
PLUGIN_SERVICE=${PLUGIN_NAME}.service
PLUGIN_APP_GUID=${ALLXON_PLUGIN_DIR##*/}

if [ -d $ALLXON_PLUGIN_DIR ]; then
echo "ERROR: plugin $PLUGIN_APP_GUID already installed"
exit 1
else
mkdir -p $ALLXON_PLUGIN_DIR || exit 1
fi

check_for_install() {
echo "check for install..."
# If users try to install this plugIN on non-Ubuntu x86 devices, then it will be returned
EXECUTABLE_DESCRIPTION=$(file $CURRENT_SH_DIRECTORY/$PLUGIN_APP_GUID/$PLUGIN_NAME)
ARCH=$(uname -i)

if [[ "$ARCH" == "x86_64" ]]; then
ARCH="x86-64"
fi

if [[ "$EXECUTABLE_DESCRIPTION" != *"$ARCH"* ]]; then
>&2 echo "Not Supported Architecture"
exit 1
fi
}

install_plugin_files() {
echo "install plugin files..."
cp -r ./$PLUGIN_APP_GUID/* $ALLXON_PLUGIN_DIR || exit 1
echo "\
[Unit]
Description=Allxon Hello plugIN
Documentation=https://dms.allxon.com/

[Service]
Type=simple
ExecStart=${ALLXON_PLUGIN_DIR}/${PLUGIN_NAME} ${ALLXON_PLUGIN_DIR}
Environment="HOME=/root"
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
" > ${PLUGIN_SERVICE} || exit 1

cp ./$PLUGIN_SERVICE /etc/systemd/system/ || exit 1
echo "plugIN is installed to $ALLXON_PLUGIN_DIR"
}

initial_plugin_service_in_system() {
echo "start service..."
systemctl daemon-reload || exit 1
chmod 644 /etc/systemd/system/$PLUGIN_SERVICE || exit 1
systemctl enable --now $PLUGIN_SERVICE || exit 1
}

install_plugIN() {
check_for_install
install_plugin_files
initial_plugin_service_in_system > /dev/null 2>&1
sleep 1
exit 0
}

install_plugIN

Versioning

You can update Verison number under CMakeLists.txt, following Semantic Versioning format. Remember to rebuild it after update version.

caution

If you update v2/notifyPluginUpdate content, you must release a new Plugin version. It will affect Allxon Portal Plugin Verification.

CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
project(plugin-hello VERSION 1.0.1)
set(OCTO_SDK_VERSION 3.0.0)
# ...

Or your can use release.sh to update version.

./release.sh 1.0.1

Test your Plugin Package

Before you upload your Plugin Package to Allxon Plugin Center, You should test your package on local. You install your Plugin Package on local through Plugin Online installer.

Install Plugin Package

sudo wget -qO - https://get.allxon.net/plugIN/linux | sudo  bash -s -- --app-guid [APP_GUID] --from-path [PLUGIN_PACKAGE]

After that, you can check if your installation is ok.

Uninstall Plugin Package

sudo wget -qO - https://get.allxon.net/plugIN/linux | sudo  bash -s -- --app-guid [APP_GUID] --remove